package mobilizator.app.list;

import java.util.ArrayList;
import mobilizator.app.R;
import mobilizator.app.data.Category;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ClothCategoriesAdapter extends BaseAdapter {

	private LayoutInflater inflater;
	private ArrayList<Category> categories;
	
	public ClothCategoriesAdapter(Context ctx, ArrayList<Category> categories) {
		this.inflater = (LayoutInflater) ctx
		        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.categories = categories;
	}
	
	public int getCount() {
		return categories.size();
	}

	public Category getItem(int arg0) {
		return categories.get(arg0);
	}

	public long getItemId(int arg0) {
		return arg0;
	}

	public View getView(int arg0, View arg1, ViewGroup arg2) {
		arg1 = inflater.inflate(
				R.layout.cloth_list_categories_row, arg2, false);
		TextView category = (TextView) arg1.findViewById(R.id.cloth_list_categories_category);
		category.setText(categories.get(arg0).getName());
		return arg1;
	}
	
}